<?php
namespace app\api\controller;

use app\hprose\controller\HproseServer;

//RPC server
class TestServer extends HproseServer
{

    public function __construct()
    {
        parent::__construct();

    }

    //http://ela.test/api/TestServer/func1
    public function func1()
    {
//        echo "func1";    //由于Hprose是采用序列化&反序列化机制，任何类似echo 的直接输出语句都属于错误的调用。不会有任何实际输出
        return "func1sadfasdf";
    }
    
    public function func2()
    {
        return ["name"=>"小明", "age"=>"25", "gender"=>"男", "score"=>60];
    }

    //http://ela.test/api/TestServer/func3?num1=1&num2=3
    public function func3($num1, $num2)
    {
        return "func3-".$num1." -".$num2;
    }

    //cars = ["Porsche", "Volvo", "BMW"]
    public function func4($arrayA)
    {
        if (!is_array($arrayA)) {
            return "not array";
        }
        return "func3-".$arrayA['0']." -".$arrayA['1'];
    }
    /*
        x = {
            "name": "Bill",
            "age": 63,
            "city": "Seatle"
        }
    */
    public function func5($arrayA)
    {
        if (!is_array($arrayA)) {
            return "not array";
        }
//        return "func3-".$arrayA['name']." -".$arrayA['age'];
        $arrayA['age'] = 99;
        return $arrayA;
    }

}